package com.hundsun.s3.common.dto;


import com.hundsun.jresplus.ui.page.Page;

/**
 * @Description: 需要先传入总数!!先设置pageSize 后设置pageNo
 * @Author: yangjun23614
 * @Date: 10:31 2018/2/9
 * V1.0
 */
public class PageBean extends Page {

    public void setPNoPSize(int PNo,int PSize){
        if(PNo != 0 && PSize != 0 ) {
            this.setPageNo(PNo);
            this.setPageSize(PSize);
        } else if (PNo == 0 && PSize != 0){
            this.setPageNo(1);
            this.setPageSize(PSize);
        } else if(PNo != 0 && PSize == 0){
            this.setPageNo(PNo);
            this.setPageSize(10);
        } else {
            this.setPageNo(1);
            this.setPageSize(10);
        }
    }

    public int getStart() {
        int i =  ((super.getPageNo()<1?1:super.getPageNo())-1)*super.getPageSize()+1;
        return i;
    }

    /**
     * @Description:传入行数，计算其页码
     * @Author: yangjun23614
     * @Date: 14:44 2018/2/9
     * V1.0
     */
    public void setStart(int start) {
        if(1>start){
            start=1;
        }
        int i = (start-1)/super.getPageSize()+1;
        super.setPageNo(i);
    }
    
    /**
     * @Description:
     * @return:  结束行
     * @Author: yangjun23614
     * @Date: 11:20 2018/2/9
     * V1.0 
     */
    public int getEnd(){
        return this.getStart()+getPageSize()-1;
    }

}
